package com.dt76.smallloanbackendservice.controller.lhuaw;


import com.dt76.smallloanbackendservice.pojo.lhuaw.UserFeedback;
import com.dt76.smallloanbackendservice.service.lhuaw.UserFeedbackService;
import com.dt76.smallloanbackendservice.utils.Page;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;


@Controller
@RequestMapping("/lhuaw")
public class UserFeedbackController {
    @Resource
    private UserFeedbackService userFeedbackService;

    @RequestMapping("/qryAllFeedback")
    @ResponseBody
    public List<UserFeedback> qryAllFeedback(){
        return userFeedbackService.qryAllFeedback();
    }

    @RequestMapping("/qryConditionPageAllFeedback")
    @ResponseBody
    public Page qryConditionPageAllFeedback(@RequestParam("pageIndex")  int pageIndex,
                                            @RequestParam("userName") String userName,
                                            @RequestParam("feedbackQuestion") String feedbackQuestion){
        System.out.println("成功调用远程");

        return userFeedbackService.qryConditionPageAllFeedback(pageIndex, userName, feedbackQuestion);
    }
//删除
    @RequestMapping("/deleteFeedback")
    @ResponseBody
    public Result delSystem(@RequestParam("ufId")int ufId){
        System.out.println("成功调用删除方法，正在执行UserFeedbackService.deleteFeedback>>>>>>>>");
        try {
            userFeedbackService.deleteFeedback(ufId);
            return new Result(true,"删除成功>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>");
        }
    }

}
